package com.th.contraller;

import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletContextEvent;
import jakarta.servlet.ServletContextListener;
import jakarta.servlet.annotation.WebListener;

import java.lang.annotation.Annotation;
import java.sql.Date;
import java.time.LocalDate;
@WebListener
public class StartListen implements ServletContextListener {
    @Override
    public void contextInitialized(ServletContextEvent sce) {
        ServletContext ctx = sce.getServletContext();
        Date date = Date.valueOf(LocalDate.now());
        String year = String.valueOf(date.getYear()).substring(1,3);
        String month = String.valueOf(date.getMonth()+1);
        if(month.length() == 1)
        {
            month = "0"+month;
        }
        String day = String.valueOf(date.getDate());
        if(day.length() == 1)
        {
            day = "0"+day;
        }
        ctx.setAttribute("get_id",Integer.parseInt(year +month +day)*100);
    }
}
